package com.a.b.c.demo;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class Demo3 {
    public static void main(String[] args) {
        /*
        自定义线程池：
        ThreadPoolExecutor(
            int corePoolSize,       -- 最大核心线程数
            int maximumPoolSize,    -- 最大线程数
            long keepAliveTime,     -- 临时线程存活时间
            TimeUnit unit,          -- 存活时间单位
            BlockingQueue<Runnable> workQueue,   -- 阻塞队列
            ThreadFactory threadFactory,         -- 创建线程方式
            RejectedExecutionHandler handler     -- 拒绝策略
        )
         */
        ThreadPoolExecutor pool = new ThreadPoolExecutor(3,6,60, TimeUnit.SECONDS, new ArrayBlockingQueue<>(10),Executors.defaultThreadFactory(), new ThreadPoolExecutor.AbortPolicy());

        pool.submit(new Runnable() {
            @Override
            public void run() {
                System.out.println("嘿嘿嘿");
            }
        });

        pool.submit(() -> {
            System.out.println("hhh");
        });
        pool.shutdown();
    }
}
